import React, {Component, Fragment} from 'react';
import PropTypes from 'prop-types';
import {Table, Tag, Button, Drawer} from 'antd';

import './JurisdictionTableList.scss';

class JurisdictionTableList extends Component {

  state = {

    columns: [
      {
        title: 'ID',
        dataIndex: 'permission_id',
        key: 'permission_id'
      },
      {
        title: '权限名称',
        dataIndex: 'title',
        key: 'title'
      },
      {
        title: '权限路径',
        dataIndex: 'path',
        key: 'path'
      },
      {
        title: '是否显示',
        dataIndex: 'is_show',
        key: 'is_show',
        render: (text, record) => {
          return record.is_true ? '显示' : '隐藏';
        }
      },
      {
        title: '是否禁用',
        dataIndex: 'is_true',
        key: 'is_true',
        render: (text, record) => {
          return record.is_true ? '启用' : '禁用';
        }
      },
      {
        title: '操作',
        key: 'action',
        render: (text, record) => {
          const {jurisdictionEdit} = this.props;
          return <div className='actionGroup'>
            <Button size='small' onClick={() => jurisdictionEdit(record)}>编辑</Button>
            {/*<Button size='small' type='danger' onClick={() => this.jurisdictionDel(record)}>删除</Button>*/}
          </div>;
        }
      }
    ]
  };
  static propTypes = {
    jurisdictionList: PropTypes.array,
    jurisdictionEdit: PropTypes.func
  };

  jurisdictionDel = data => {
    console.log(data);
  };

  render() {
    const {columns} = this.state;
    const {jurisdictionList: data} = this.props;
    return (
      <div className='JurisdictionTableList'>
        <Table columns={columns} dataSource={data} pagination={false}/>
      </div>
    );
  }

}

export default JurisdictionTableList;
